package servlet;

import dao.BlogDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete")
public class DeleteServlet extends HttpServlet {
    public BlogDao blogDao = new BlogDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;cahrset=utf8");
        String blogIdParam = req.getParameter("blogId");
        if (blogIdParam==null || "".equals(blogIdParam)){
            resp.getWriter().write("blogId不正确");
            return;
        }
        Integer blogId = Integer.parseInt(blogIdParam);
        blogDao.deleteBlog(blogId);
        resp.sendRedirect("blog_list.html");

    }
}